﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Shared/MasterAdmin.master" AutoEventWireup="true"
    CodeFile="AddProduct.aspx.cs" Inherits="Admin_AddProduct" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <script type="text/javascript">
        function uploadComplete1(sender, args) {
            try {

                var fileExtension = args.get_fileName();

                if (fileExtension.toLowerCase().indexOf('.jpg') != -1 ||
                    fileExtension.toLowerCase().indexOf('.gif') != -1 ||
                    fileExtension.toLowerCase().indexOf('.png') != -1) {
                    $get("dvFileErrorInfo1").style.display = 'none';
                    return true;
                }
                else {
                    $get("dvFileErrorInfo1").style.display = 'block';
                    $get("<%=lblError1.ClientID %>").innerHTML = "File extesion not supported";
                    return;
                }

            } catch (e) {

            }
        }
        function uploadComplete2(sender, args) {
            try {

                var fileExtension = args.get_fileName();

                if (fileExtension.toLowerCase().indexOf('.jpg') != -1 ||
                    fileExtension.toLowerCase().indexOf('.gif') != -1 ||
                    fileExtension.toLowerCase().indexOf('.png') != -1) {
                    $get("dvFileErrorInfo2").style.display = 'none';
                    return true;
                }
                else {
                    $get("dvFileErrorInfo2").style.display = 'block';
                    $get("<%=lblError2.ClientID %>").innerHTML = "File extesion not supported";
                    return;
                }

            } catch (e) {

            }
        }
    </script>
    <h1>
        Add Product</h1>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table style="width: 100%;">
                <tr>
                    <td>
                        Category
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlCategory" runat="server" DataTextField="cName" DataValueField="cId"
                            AutoPostBack="true" OnSelectedIndexChanged="ddlCategory_SelectedIndexChanged"
                            OnLoad="ddlCategory_Load">
                            <asp:ListItem>All Category</asp:ListItem>
                        </asp:DropDownList>
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ShopConnectionString %>"
                            SelectCommand="SELECT * FROM [Categories] WHERE ([cActive] = @cActive)">
                            <SelectParameters>
                                <asp:Parameter DefaultValue="true" Name="cActive" Type="Boolean" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="ddlCategory"
                            ErrorMessage="Choose One" ForeColor="Red" InitialValue="All Category"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        ProductCode
                    </td>
                    <td>
                        <asp:TextBox ID="txtProductCode" runat="server" ReadOnly="True"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        Name
                    </td>
                    <td>
                        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtName"
                            ErrorMessage="Required Name" ForeColor="Red"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        Small Image
                    </td>
                    <td>
                        <%--<asp:FileUpload ID="fuSmall" runat="server" />--%>
                        <asp:AsyncFileUpload ID="fuSmall" runat="server" OnUploadedComplete="fuSmall_UploadedComplete"
                            OnClientUploadComplete="uploadComplete1" UploaderStyle="Modern" UploadingBackColor="#CCFFFF"
                            ThrobberID="myThrobber" />
                        <asp:Label runat="server" ID="myThrobber" Style="display: none;">

                     <img src="../Script/Style/images/ajax-loader.gif" />

                        </asp:Label>
                    </td>
                    <td>
                        <div style="border-style: solid; display: none; width: 350px" id="dvFileErrorInfo1">
                            <asp:Label ID="lblErrorStatus1" Font-Bold="true" runat="server" Text="Status:-" /><asp:Label
                                ID="lblError1" ForeColor="Red" runat="server" /><br />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        Big Image
                    </td>
                    <td>
                        <%-- <asp:FileUpload ID="fuBig" runat="server" />--%>
                        <asp:AsyncFileUpload ID="fuBig" runat="server" OnUploadedComplete="fuBig_UploadedComplete"
                            OnClientUploadComplete="uploadComplete2" UploaderStyle="Modern" UploadingBackColor="#CCFFFF"
                            ThrobberID="myThrobber" />
                    </td>
                    <td>
                        <div style="border-style: solid; display: none; width: 350px" id="dvFileErrorInfo2">
                            <asp:Label ID="lblErrorStatus2" Font-Bold="true" runat="server" Text="Status:-" /><asp:Label
                                ID="lblError2" ForeColor="Red" runat="server" /><br />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        Description
                    </td>
                    <td>
                        <asp:TextBox ID="txtDescription" runat="server" Height="52px" TextMode="MultiLine"
                            Width="227px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtDescription"
                            ErrorMessage="Required Description" ForeColor="Red"></asp:RequiredFieldValidator>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        Quantity
                    </td>
                    <td>
                        <asp:TextBox ID="txtQuantity" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtQuantity"
                            ErrorMessage="Required Quantity" ForeColor="Red"></asp:RequiredFieldValidator>
                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="txtQuantity"
                            ErrorMessage="Number" ForeColor="Red" Operator="DataTypeCheck" Type="Integer"></asp:CompareValidator>
                        <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txtQuantity"
                            ErrorMessage="Number between 1 and 1000" ForeColor="Red" MaximumValue="1000"
                            MinimumValue="1" Type="Integer"></asp:RangeValidator>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        Price
                    </td>
                    <td>
                        <asp:TextBox ID="txtPrice" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtPrice"
                            ErrorMessage="Required Price" ForeColor="Red"></asp:RequiredFieldValidator>
                        <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="txtPrice"
                            ErrorMessage="Number" ForeColor="Red" Operator="DataTypeCheck" Type="Integer"></asp:CompareValidator>
                        <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="txtPrice"
                            ErrorMessage="Number between 1000 and 1000000000" ForeColor="Red" MaximumValue="100000000"
                            MinimumValue="1000" Type="Integer"></asp:RangeValidator>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        Active
                    </td>
                    <td>
                        <asp:CheckBox ID="chkActive" runat="server" />
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <asp:Button ID="btnAdd0" runat="server" OnClick="btnAdd_Click" Text="Add" />
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                </tr>
            </table>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="ddlCategory" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
